package com.rhb.erp.hr.person.business;

import java.util.Iterator;
import java.util.List;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.apache.log4j.Logger;

import com.rhb.erp.hr.person.bean.Person;
import com.rhb.erp.hr.person.business.PersonBusiness;
import com.rhb.erp.hr.person.business.PersonBusinessTest;
import com.rhb.erp.hr.person.bean.PersonQuery;
import com.rhb.erp.AppContext;

public class PersonBusinessTest extends TestCase {

	static Logger logger = Logger.getLogger(PersonBusinessTest.class);

	private PersonBusiness pBusiness;

	protected void setUp() {
		pBusiness = (PersonBusiness) AppContext.getInstance().getAppContext()
				.getBean("personService");

	}
	
	public void test_findByQuery() {
		try {
			logger.info("***** test_findByQuery  ... ");
			PersonQuery pq = new PersonQuery();
			pq.setDepartmentName("a.b");
			int start = 0;
			int count = 100;
			List list = pBusiness.findByQuery(pq, start, count);
			if(list == null){
				logger.info("list is null");
			}else{
				Person person = null;
				Iterator it = list.iterator();
				while(it.hasNext()){
					person = (Person)it.next();
					logger.info("*********");
					logger.info(person.getFullName());
					logger.info(person.getDepartment().getNameMap());
				}
			}
			
			
		} catch (Exception e) {
			fail("************* test_findByQuery error *****************");
			e.printStackTrace();
		}
	}

}
